#include "ALLMenu.h"
#include "Show.h"
#include "Archive.h"

SaveMenu::SaveMenu(IMenu *FM, PlayMenu01 *PM) {
	FatherMenu = FM;
	Name.push_back("Back");
	NextMenu = FatherMenu;
	DemoValue = PM->GetDemoValue();
	PM01 = PM;
}

SaveMenu::~SaveMenu() {

}

bool SaveMenu::process() {
	int opt = -1;
	DemoValue = PM01->GetDemoValue();
	Show show(this);
	Choose chs;
	while(opt == -1) {
		show.Save();
		opt = chs.Option(this, GetItem() + 1);
	}
	if(opt != 0) {
		std::string aname = chs.Save();
		Archives::getInstance().addArchive(DemoValue, aname, opt);
		if(opt < item) {
			Name[opt] = aname;
		} else {
			Name.push_back(aname);
			item++;
		}
	}
	MenuMgr::getInstance().SetActiveMenu(FatherMenu);
	return !OVER;
}

std::string SaveMenu::GetChildName(int k) {
	return Name[k];
}

int SaveMenu::GetItem() {
	return item;
}

std::string SaveMenu::GetMyName() {
	return Myname;
}


